module Fighter {
	/**
	 * 环绕僚机---周泽东
	 *  
	 * */
	export class AroundFly {
		constructor(tshowPanel) {
			this.showPanle = tshowPanel;

		}
		/**显示的容器*/
		public showPanle: any;
		/**玩家位置 */
		public playerPos: egret.Point;
		/**环绕型僚机 */
		public aroundPlane: egret.Bitmap;
		/**玩家 */
		public player: egret.Bitmap;
		/**环绕半径 */
		public r: number;
		/**环绕角度 */
		public angle: number;
		/**是否使用僚机 */
		public isUsed: boolean = false;

		/**环绕速度 */
		public speed: number;
		/**初始化 */
		public init(player:egret.Bitmap) {
			this.r = 100;
			this.angle = 0;
			this.speed = 10;

			this.playerPos = GameUtil.PlayerMessage.instance.player_position;
			if (this.aroundPlane == null) {
				this.aroundPlane = new egret.Bitmap();
				this.aroundPlane.texture = RES.getRes("liaoji2_png");
				this.aroundPlane.x = player.x;
				this.aroundPlane.y = player.y;


			}
			this.showPanle.addChild(this.aroundPlane);


		}
		/**环绕方法 */
		public around() {

			this.playerPos = GameUtil.PlayerMessage.instance.player_position;
			this.aroundPlane.x = this.playerPos.x + this.r * Math.cos(this.angle);
			this.aroundPlane.y = this.playerPos.y + this.r * Math.sin(this.angle);
			this.angle += this.speed * 2 * Math.PI / 360;



		}

		public removeSelf() {
			if (this.aroundPlane.parent) {
				this.aroundPlane.parent.removeChild(this.aroundPlane);

			}
		}
		/**飞机与子弹的碰撞 */
		public hittedByBullet() {
			if (this.showPanle.BulletManager) {
				let list: any[] = this.showPanle.BulletManager.productBulletus;
				for (let i = 0; i < list.length; i++) {
					let Tbullet: Bullet.BasicBullet = list[i];
					if (GameHit.GameHit(this.aroundPlane, Tbullet.bullet) && list[i].bulletType == 2) {

						Tbullet.bulletHp--;

					}
				}
			}
			if (this.showPanle.flyManager) {
				let list: any[] = this.showPanle.flyManager.productflys;
				for (let i = 0; i < list.length; i++) {
					let TFly: Fighter.BasicFly = list[i];
					if (GameHit.GameHit(this.aroundPlane, TFly.fly)) {

						TFly.hp -= 200;
					}
				}
			}
		}
	}
}